
<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<link href="../css/main.css" type="text/css" rel="stylesheet" />
		<link href="../css/dialog.css" rel="stylesheet" type="text/css">
		<script type="text/javascript" src="../datePicker/WdatePicker.js"></script>
		<title></title>
		
	</head>
	<body>
		<div class="main_frame">
			<div class="position_div">
				<img src="../images/position_icon.png" />
				<i>项目管理</i><i>&gt;&gt;</i><i>项目列表管理</i>
			</div>
			<div class="right_div">
				<div class="search_div">
				
					<div class="label_div">
						<label class="text_label">项目类型：</label>
					    <div class="drop_frame">
							<i class="text_i" data-status="0" >请选择</i>
							<input type="hidden" id="qry_itemId" value="0">
							<span class="span_arrow"></span>
							<ul class="choose_ul qry_items"></ul>
						</div>
					</div>
					
					
					<div class="label_div">
						<label class="text_label">用户：</label>
						<input type="text" class="input_search" placeholder="支持模糊查询" id="qry_brand" />
					</div>
					<div class="label_div">
						<label class="text_label">项目代码：</label>
						<input type="text" class="input_search" placeholder="支持模糊查询" id="qry_pro_id" />
					</div>
					<div class="label_div">
						<label class="text_label">归属经销商：</label>
						<input type="text" class="input_search" placeholder="支持模糊查询" id="qry_dealerName" />
					</div>
					<!-- <div class="label_div">
						<label class="text_label">安装日期：</label>
						<input type="text" class="input_search"  id="qry_brand" />
					</div>
					<div class="label_div">
						<label class="text_label">至：</label>
						<input type="text" class="input_search"  id="qry_brand" />
					</div>
					 -->
					
					<!-- <div class="label_div">
						<label class="text_label">地区：</label>
						<input type="text" class="input_search" placeholder="支持模糊查询" id="qry_area" />
					</div>
					<div class="label_div">
						<label class="text_label">设备号：</label>
						<input type="text" class="input_search" placeholder="支持模糊查询" id="qry_device_No" />
					</div> -->
					<div class="done_div">
						<button class="btn_common1 title_div2"  onclick="qryItemListBtn()">
							<i></i>搜索
						</button>
						<button style="margin-left:10px !important" class="btn_common2 newadd"   onclick="toAddForm()">
							<i></i>新增
						</button>
					</div>
                    <div class="cl">&nbsp;</div>
				</div>
				<table class="table_list">
					<tr>
						<th width="6%">序号</th>
						<th width="12%">项目代码</th>
						<th width="12%">项目名称</th>
						<!-- <th width="10%">安装时间</th>
						<th width="12%">运行时间</th> -->
						<th width="10%">关联用户</th>
						<th width="10%">关联设备</th>
						<th width="10%">归属经销商</th>
						
						<th class="last_td">操作</th>
					</tr>
					<tbody id="listbox1">
					</tbody>
				</table>
				<div class="turn_page" style="display:none">
				   <div class="main_page" id="pageCon">
					   <a href="javascript:void(0)" class="first_a" id="firstPage"></a>
					   <a href="javascript:void(0)" class="up_a" id="prev"></a>    	
					   <a href="javascript:void(0)" class="next_a" id="next"></a>
					   <a href="javascript:void(0)" class="last_a" id="lastPage"></a>
					   <input id="page_num_input" style="width:40px;" type="text" onblur="checkValue(this);" onkeyup="value=value.replace(/\D/g,'')"/>
					   <button type="button" class="num_input" id="go_num_input">跳转</button>
					   <b class="page_text">当前<i><em id="nowpage"></em>/<em id="totalpage"></em></i>页，总数<i id="totalNum"></i>条</b>    	
				   </div>
				</div>
				
				
				
				
				<div class="opacity_div" style="display: none;"></div>
				<div class="bookDetail" id="bookDetail1" style="display: none;top:20px;margin-bottom: 20px;">
					<div class="prop_top">
						<i>新增项目</i>
						<a href="javascript:void(0)" class="close_icon"><img src="../images/close_icon.png"></a>
					</div>
					<div class="bookdetail_box">
					<form action="" id="form">
						
<!-- 						<input type="hidden" name="deviceIds" id="deivces_a"/> -->
					
						<div class="blank_div"></div>
						<input type="hidden" class="input_search width_input" name="id" value="0"/>
						<div class="blank_div"></div>
						<label class="text_label label_width">项目名称：</label>
					    <input type="text" class="input_search width_input notNull" name="name" />
					    &nbsp;&nbsp;<span style="color: red">* </span>
					    <div class="blank_div"></div>
						<label class="text_label label_width">项目类型：</label>
						<div class="drop_frame">
							<i class="text_i" data-status="0">请选择</i>
							<span class="span_arrow"></span>
							<input type="hidden" name="typeId"  class="input_search  notNull"  id="itemTypeId_a">
							<ul class="choose_ul itemType"></ul>
						</div>					    
					    &nbsp;&nbsp;<span style="color: red">* </span>
					    
					   <!--  <div class="blank_div"></div>
					    <label class="text_label label_width">安装日期：</label>
					     <input type="text" class="input_search width_input date " name="installTimeStr" data-name="installTime" 
					     onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'});" />
					     &nbsp;&nbsp;<span style="color: red">* </span>
					     -->
					    
					    
					    <div class="blank_div"></div>
					    
						<label class="text_label label_width">选择客户：</label>
						<div class="drop_frame">
							<i class="text_i" data-status="0">请选择</i>
							<span class="span_arrow"></span>
							<input type="hidden" name="userId" id="userId_a" >
							<ul class="choose_ul items"></ul>
						</div>
						&nbsp;&nbsp;<span style="color: red">* </span>
						
					   <!--  <div class="blank_div"></div>
					    <label class="text_label label_width">选择时间区间：</label>
					     <input type="text" class="input_search width_input date " name="produceTimeStr" data-name="produceTime" 
					     onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'});" />
					     &nbsp;&nbsp;<span style="color: red">* </span> -->
					    
					   <!--  <div class="blank_div"></div>
					    <label class="text_label label_width">关联设备：</label>
					    <button class="btn_common2"  onclick="adddiv()">添加</button>
					    <div class="blank_div"></div>
					    <div>
							<table class="table_list">
								<tbody id="listbox2">
									
								</tbody>
							</table>
							
					    </div>
					     -->
					     <div style="display: none;">
						     <div class="blank_div"></div>
						     <label class="text_label label_width">省：</label>
	                        <input type="text" class="input_search width_input " name="province" />
	                        <div class="blank_div"></div>
	                        <label class="text_label label_width">市：</label>
	                        <input type="text" class="input_search width_input " name="city" />
	                        <div class="blank_div"></div>
	                        <label class="text_label label_width">区/县：</label>
	                        <input type="text" class="input_search width_input " name="area" />
						</div>
					    <div class="blank_div"></div>
					   
					   <div>
					       <div class="address_info" >
                            <div id="container" class="allmap_test" style="height: 400px;width: 550px;left: 25px;"></div>
                        
                        <div class="blank_div"></div>
                        <label class="text_label label_width">经度：</label>
                        <input type="text" class="input_search width_input address_longitude" name="longitude" />
                    
                        <div class="blank_div"></div>
                        <label class="text_label label_width"> 纬度：</label>
                        <input type="text" class="input_search width_input address_latitude" name="latitude" />
                        
                    
                        <div class="blank_div"></div>
                        <label class="text_label label_width">地址：</label>
                        <input type="text" class="input_search width_input " name="address" />
					   
					   </div>
					   
					   
					</form>
					<div class="blank_div"></div>
					<div class="bottom_donebtn width_div">
						<button class="btn_common2"  onclick="itemFormSubmit()">提交</button>
						<button class="btn_common1" onclick="edit_cancel()">取消</button>	
					</div>
					<div class="blank_div"></div>
					</div>
					
				</div>
				
			</div>
			
			<!--关联设备 -->
			 <div class="bookDetail" id="bookDetail3" style="display: none;top:150px;">
			        <inpit type="hidden" id="binddevproId" />
                    <div class="prop_top">
                        <i>设备列表</i>
<!--                         <a href="javascript:void(0)" class="close_icon"><img src="../images/close_icon.png"></a> -->
                    </div>
                    <div class="bookdetail_box">
                    <div>
                     <label class="text_label">已绑定设备:</label>
                         <table class="table_list">
                            <tr>
                                <th width="2%"></th>
                                <th width="30%">设备名称</th>
                                <th width="20%">设备序列号</th>
                                <th width="20%">设备类型</th>
                                <th width="10%">操作</th>
                            </tr>
                             <tbody id="listbox3">
                                 
                             </tbody>
                         </table>
                    </div>
                    <div>
                    
                         <div class="blank_div"></div>
                         <hr>
	                     <label class="text_label">未绑定设备:</label>
	                     
                         <div class="blank_div"></div>
	                     <div id="bindQryThing">
		                     <div class="label_div">
	                            <input type="text" class="input_search" style="width: 90px";  placeholder="设备名称" id="qry_device_name" />
	                        </div>
	                       <div class="label_div">
                                <input type="text" class="input_search" style="width: 80px"; placeholder="设备序号" id="qry_device_no" />
                            </div>
                            <!-- <div class="label_div">
                                <div class="drop_frame" style="width: 120px";>
	                                <i class="text_i" data-status="0" >设备型号</i>
	                                <span class="span_arrow"></span>
	                                <input type="hidden" name="typeId" >
	                                <ul class="choose_ul type_device_html"></ul>
                                </div>  
                            </div>  -->
                            <div class="done_div">
		                        <button style="margin-left:10px !important" class="btn_common2"   onclick="clearinputBind()">
		                            <i></i>清空条件
		                        </button>
		                        <button class="btn_common1 title_div2"  onclick="qryNoBindDevices()">
		                            <i></i>搜索
		                        </button>
		                    </div>
	                     </div>
                          <table class="table_list">
                            <tr>
<!--                                 <th width="2%" ></th> -->
                                <th width="4%" colspan="2"><input type="checkbox" name="allDevCk" id="allDevCk" /></th>
                                <th width="25%">设备名称</th>
                                <th width="20%">设备序列号</th>
                                <th width="20%">设备类型</th>
                            </tr>
                             <tbody id="listbox4">
                                 
                             </tbody>
                         </table>
                    </div>
                    <div class="blank_div"></div>
                    <div class="bottom_donebtn width_div">
                        <button class="btn_common2" onclick="bindDevCk()">确定</button> 
                        <button class="btn_common1" onclick="edit_cancel()">取消</button> 
                    </div>
                    
                    </div>
                    <div class="blank_div"></div>
                </div>
			
			<!--已关联的设备 -->
             <div class="bookDetail" id="bookDetail4" style="display: none;top:20px;width:65%;height:80%;left:15%">
                    <div class="prop_top">
                        <i>设备列表</i>
                        <a href="javascript:void(0)" class="close_icon"><img src="../images/close_icon.png"></a>
                    </div>
                    <iframe id="myIframe" src="deviceListTemp" marginheight="0" marginwidth="0" 
                    frameborder="no" style="width:100%;height:100%; " align="middle"></iframe>
                    
             </div>
			
			
		</div>
		<script type="text/javascript" src="../js/jquery-1.10.2.min.js"></script>
		<script type="text/javascript" src="../js/common.js"></script>
		<script type="text/javascript" src="../js/dialog.js"></script>
		<script type="text/javascript" src="../js/jquery-data.js"></script>
		<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=6a8c6407384cecce12aef8f55109e024"></script>
        <script type="text/javascript" src="../js/map.js"></script>
        <script type="text/javascript" src="../js/cookieUtil.js"></script>
		<script type="text/javascript">
			var yema=1;
			var pagelen=10;
			var totalPage=0;   
			function qryList(){		
				qryItemList();
			}
			
			//清空查询条件
			function clearinputBind(){
			 
			     $("#qry_device_name").val("");
			     $("#qry_device_no").val("");
			}
			
			$(document).ready(function(){
				getDictionaryList(1);
				qryUserList();
				getModelList();
				qryList();
			});
			function qryList(){
				qryItemList();
			}
			function qryItemListBtn(){
				 yema=1;
				qryItemList();
			}
			function qryItemList(){
				$.ajax({
					url: 'qryProjectList', 
					type: 'POST',
					data:{typeId:$("#qry_itemId").val(),
						username:$("#qry_brand").val(),
						projectNo:$("#qry_pro_id").val(),
						dealerName:$("#qry_dealerName").val(),
						qryAddressName:$("#qry_area").val(),
						deviceId:$("#qry_device_No").val(),
						yema:yema,length:pagelen},
					async: false,
					dataType: 'json', 
					timeout: 10000, 
					error: function(){LQWarn('请求失败,请稍后重试');}, 
					success: function(result){
						console.log(result);
						if(result.resultCode==1000){
							var items=result.returnObject.pageList;
							if (items && items.length > 0) {
								var rlist="";
								var item ;
								
								$.each(items,function(i){
									item = items[i];
									rlist+='<tr data-status ="'+ item.id+'"><td>'
										+ (i+1+length*(result.returnObject.curPage-1))
										+ '</td><td><a title="查看详情" href="javascript:void(0);" onclick="showDeviceByItem2('+item.id+')">' 
										+ item.projectNo
										+ '</a></td><td><a title="查看详情" href="javascript:void(0);" onclick="showDeviceByItem2('+item.id+')">' 
										+ item.name
										+ '</a></td><td>' 
										/* + formatToDate(item.installTime)
										+ '</td><td>' 
										+ getDays(formatToDate(item.installTime), CurentTime())+ '天'
										+ '</td><td>'  */
										+ item.username
										+'</td><td> <a title="修改" href="javascript:void(0);" onclick="showDeviceByItem('+item.id+')">关联</a>'
										+'</td><td>'
										+ item.dealerName
										+'</td><td class="last_td">'
										+ '<a class="mod" title="修改" href="javascript:void(0);" onclick="toEditForm(this)">修改</a>'
										+ '<a class="del" title="删除" href="javascript:void(0);" onclick="delItem(this)">删除</a>'
// 										+ '<a class="mod" title="设备管理" href="javascript:void(0);" onclick="">设备</a>'
										
										+ '</td></tr>';
								});
								$("#listbox1").html(rlist);
								totalPage=result.returnObject.totalPage;
								$("#nowpage").html(result.returnObject.curPage);
								$("#totalpage").html(totalPage)
								$("#totalNum").html(result.returnObject.totalNum);
								$(".turn_page").show();
							}else{
								$("#listbox1").html("");
								$(".turn_page").hide();
							}
						}
						else if(result.resultCode==1004){
							LQWarn(result.returnObject);
							window.top.location.href ="../login.jsp";
						}else{
							LQWarn(result.returnObject);
						}
					}
				});
			}
			//查询未绑定项目的设备
			function qryNoBindDevices(){
			   showDeviceByItem($("#binddevproId").val());
			}
			//点击项目名打开相关设备列表
			function showDeviceByItem2(itemid){
				$("#myIframe").attr("src","deviceListTemp?id="+itemid)
				$(".opacity_div,#bookDetail4").show();
			  // window.location.href ="deviceListTemp?id=222"
			}
			//查看绑定的设备信息
			function showDeviceByItem(itemid){
				$(".opacity_div,#bookDetail3").show();  
				$("#binddevproId").val(itemid); 
			         
			    var dname = $("#qry_device_name").val();
                var dno = $("#qry_device_no").val();
			     
			     
			     if(dname||dno){
                                itemid = 0;
                            }
			     
			     $.ajax({
                    url: '../device/qryDeviceList', 
                    type: 'POST',
                    async: false,
                    traditional:true,
                    data:{yema:1,length:100,projectId:itemid,projectIdNoBind:-1,serialNumber:dno,name:dname},
                    dataType: 'json', 
                    timeout: 10000, 
                    error: function(){LQWarn('请求失败,请稍后重试');}, 
                    success: function(result){
                        if(result.resultCode==1000){
                            var items = result.returnObject.pageList;
                            var item;
                            var html_items = "";
                            var html_items_2 = "";
                            console.log(items)
                            var xu = 0;
                            var xun = 0;
                            if(items){
                                for(var i=0;i<items.length;i++){
                                    item = items[i];
                                    if(!item.projectId){
                                    xu++;
                                        html_items_2  += '<tr>'
// 	                                        +'<td><img alt="" src="" width="30px" height="30px"></td>'
                                            +'<td>'+xu+'</td>'
                                            +'<td><input type="checkbox" name="noBindDev" value="'+item.id+'"/></td>'
	                                        +'<td>'+item.name+'</td><td>'+replaceNull(item.serialNumber)+'</td><td>'+replaceNull(item.modelName)+'</td>'
	                                        +'</tr>'; 
                                    }else{
                                    xun++;
                                        html_items  += '<tr>'
                                          +'<td>'+xun+'</td>'
// 	                                        +'<td><img alt="" src="" width="30px" height="30px"></td>'
	                                        +'<td>'+item.name+'</td><td>'+replaceNull(item.serialNumber)+'</td><td>'
	                                        +replaceNull(item.modelName)+'</td><td><a href="javascript:void(0)" onclick="celDeviceBind('+item.id+')">解绑</a></td>'
	                                        +'</tr>';  
                                    }     
                                }
                            }
                            if(!dname&&!dno){
	                            $("#listbox3").html(html_items);
                            }
                            $("#listbox4").html(html_items_2);
                            //加载设备模板型号 
                           // getDictionaryList(2);
                        }
                        else if(result.resultCode==1004){
                            LQWarn(result.returnObject);
                            window.top.location.href ="../login.jsp";
                        }else{
                            LQWarn(result.returnObject);
                        }
                    }
                }); 
			     
			}
			//绑定设备
            function bindDevCk(){
                var projectId = $("#binddevproId").val(); 
                 var s = checkboxvalues();
                if(s.length>0){
                    console.log(s.join(','));
                }else{
                    LQWarn('至少要选择一台设备绑定');
                   return;
                }
                $.ajax({
                    url: '../device/bindDeviceProject', 
                    type: 'POST',
                    async: false,
                    traditional:true,
                    data:{projectId:projectId,deviceIds:s.join(',')},
                    dataType: 'json', 
                    timeout: 10000, 
                    error: function(){LQWarn('请求失败,请稍后重试');}, 
                    success: function(result){
                        if(result.resultCode==1000){
                          LQWarn('绑定完成!');
                          edit_cancel();
                        }
                        else if(result.resultCode==1004){
                            LQWarn(result.returnObject);
                            window.top.location.href ="../login.jsp";
                        }else{
                            LQWarn(result.returnObject);
                        }
                    }
                }); 
                
            }
			//解除绑定设备
			function celDeviceBind(id){
				$.ajax({
	                    url: '../device/celBindDeviceProject', 
	                    type: 'POST',
	                    async: false,
	                    traditional:true,
	                    data:{id,id},
	                    dataType: 'json', 
	                    timeout: 10000, 
	                    error: function(){LQWarn('请求失败,请稍后重试');}, 
	                    success: function(result){
	                        if(result.resultCode==1000){
	                          LQWarn('解除成功!');
	                          //edit_cancel();
	                          clearinputBind();
	                          showDeviceByItem($("#binddevproId").val());
	                        }
	                        else if(result.resultCode==1004){
	                            LQWarn(result.returnObject);
	                            window.top.location.href ="../login.jsp";
	                        }else{
	                            LQWarn(result.returnObject);
	                        }
	                    }
	                }); 
			}
			
			var url_ = "addDevice.do";
			
			function toAddForm(){
				$(".opacity_div,#bookDetail1").show();	
				url_ = "addProject.do";
				$("#form").clearForm();
				//清空数据
				$("#itemTypeId_a,#userId_a").val("");
				//加载设备列表
				//showDeviceInfo();
				
			}
			//加载设备列表
			function showDeviceInfo(){
				$.ajax({
					url: '../device/qryDeviceList', 
					type: 'POST',
					async: false,
					traditional:true,
					data:{yema:1,length:100},
					dataType: 'json', 
					timeout: 10000, 
					error: function(){LQWarn('请求失败,请稍后重试');}, 
					success: function(result){
						if(result.resultCode==1000){
							var items = result.returnObject.pageList;
							var item;
							var html_items = "";
							console.log(items)
							if(items){
								for(var i=0;i<items.length;i++){
									item = items[i];
									html_items  += '<tr>'
										+'<td><input type="checkbox" name="dck" value="'+item.id+'">'
										+'<td><img alt="" src="" width="30px" height="30px"></td>'
										+'</td><td>'+item.name+'<br>'+item.mark+'</td><td>创建人:<br>'+item.username+'</td><td>查看</td>'
										+'</tr>';		
								}
							}
							$("#listbox2").html(html_items);
						}
						else if(result.resultCode==1004){
							LQWarn(result.returnObject);
							window.top.location.href ="../login.jsp";
						}else{
							LQWarn(result.returnObject);
						}
					}
				});	
			}
			
			
			
			//添加设备
			function adddiv(){
				$(".opacity_div,.bookDetail2").show();	
				url_ = "../device/addDevice.do";
				$("#form2").clearForm();
			}
    
			//提交新增项目
			function itemFormSubmit(){
				console.log($("#form").serialize());
				var s = checkboxvalues();
				if(s.length>0){
					$("#deivces_a").val(s.join(','));
				}
				if($("#form").checkhaveNull()){
					return;
				}
				operateObject(url_,$("#form").serialize(),function(){edit_cancel();});
				//return;
				
				//将选择的设备绑定到项目中
				//addBindDevice();
				//console.log(s);
			}
			
			function itemFormSubmit2(){
			//	console.log($("#form").serialize());
					if($("#form2").checkhaveNull()){
					return;
				}
				operateObject(url_,$("#form2").serialize(),function(){edit_cancel();});
				//return;
				
			}
			
			function toEditForm(obj){
				var id = $(obj).parents("tr").attr("data-status");
				toAddForm();
				url_ = "editProject.do";
				getObjectWithFillData("getProjectInfo.do",{"id":id},$("#form"));
				showMapMark();
			}
			
			function delItem(obj){
				
				var id = $(obj).parents("tr").attr("data-status");
				delObject('delProject.do',{"id":id});
				
				
			}
			
			
			/* $(".close_icon").click(function(){
			     console.log(123456);
			     $(".opacity_div,#bookDetail1,#bookDetail3").hide();
			}) */
			
			function edit_cancel(){
				$(".opacity_div,#bookDetail1,#bookDetail3,#bookDetail4").hide();
			}
			function showDeviceInfoDd(id){
                console.log("去往设备详情页面!"+id);
                setCookie("device_id",id);
                location.href = "../device/deviceMonitor";
            }   
			
			function qryUserList(){
				$.ajax({
					url: '../front/qryUserList.do', 
					type: 'POST',
					async: false,
					traditional:true,
					data:{status:1,yema:1,length:100},
					dataType: 'json', 
					timeout: 10000, 
					error: function(){LQWarn('请求失败,请稍后重试');}, 
					success: function(result){
						if(result.resultCode==1000){
							console.log(result.returnObject);
							var items = result.returnObject.pageList;
							var item;
							var html_items = "";
							
							if(items){
								for(var i=0;i<items.length;i++){
									item = items[i];
									html_items  += '<li><a href="javascript:void(0)" class="choose_a" data-status="'
									+items[i].id+'" >'+ items[i].name+'</a></li>';		
								}
							}
							$(".items").html(html_items);
							//$(".qry_items").html('<li><a href="javascript:void(0)" class="choose_a" data-status="0" >全部</a></li>'+html_items);
							
							
							
						}
						else if(result.resultCode==1004){
							LQWarn(result.returnObject);
							window.top.location.href ="../login.jsp";
						}else{
							LQWarn(result.returnObject);
						}
					}
				});	
			}
			function getDictionaryList(type){
				$.ajax({
					url: '/boilerCloud/dictionary/getDictionaryList.do', 
					type: 'POST',
					async: false,
					traditional:true,
					data:{type:type},
					dataType: 'json', 
					timeout: 10000, 
					error: function(){LQWarn('请求失败,请稍后重试');}, 
					success: function(result){
						if(result.resultCode==1000){
							var items = result.returnObject;
							var item;
							var html_items = "";
							if(items){
								for(var i=0;i<items.length;i++){
									item = items[i];
									html_items  += '<li><a href="javascript:void(0)" class="choose_a" data-status="'
									+items[i].id+'" >'+ items[i].name+'</a></li>';		
								}
							}
							if(type==1){
								$(".itemType").html(html_items);
								$(".qry_items").html('<li><a href="javascript:void(0)" class="choose_a" data-status="0" >全部</a></li>'+html_items);
							}else if(type==2){
							     html_items  = '<li><a href="javascript:void(0)" class="choose_a" data-status="0" >设备型号</a></li>' +html_items;
							     $(".type_device_html").html(html_items);
							}
							
							
							
						}
						else if(result.resultCode==1004){
							LQWarn(result.returnObject);
							window.top.location.href ="../login.jsp";
						}else{
							LQWarn(result.returnObject);
						}
					}
				});	
			}

			function getModelList(){
				//alert($(obj).attr("data-status"));
				$("#typeId").attr("data-status",0).html("请选择")
				$.ajax({
					url: '/boilerCloud/model/getModelList.do', 
					type: 'POST',
					async: false,
					traditional:true,
					dataType: 'json', 
					timeout: 10000, 
					error: function(){LQWarn('请求失败,请稍后重试');}, 
					success: function(result){
						if(result.resultCode==1000){
							//console.log(result.returnObject);
							var items = result.returnObject;
							var item;
							var html_items = "";
							
							if(items){
								for(var i=0;i<items.length;i++){
									item = items[i];
									html_items  += '<li><a href="javascript:void(0)" class="choose_a" data-status="'
									+items[i].id+'">'+ items[i].name+'</a></li>';		
								}
							}
							$(".type_html").html(html_items);
							
							
						}
						else if(result.resultCode==1004){
							LQWarn(result.returnObject);
							window.top.location.href ="../login.jsp";
						}else{
							LQWarn(result.returnObject);
						}
					}
				});
			}

	
	
//全选
$("#allDevCk").click(function(){
 //console.log( $("input[name='allDevCk']").attr('type'));
    var xz = $(this).prop("checked");//判断全选按钮的选中状态
    var ck = $("input[name='noBindDev']").prop("checked",xz);  //让class名为qx的选项的选中状态和全选按钮的选中状态一致。  
})	
		
		
function getDays(strDateStart, strDateEnd) {
console.log(strDateStart);
console.log(strDateEnd);
	var strSeparator = "-"; //日期分隔符
	var oDate1;
	var oDate2;
	var iDays;
	oDate1 = strDateStart.split(strSeparator);
	oDate2 = strDateEnd.split(strSeparator);
	var strDateS = new Date(oDate1[0], oDate1[1] - 1, oDate1[2]);
	var strDateE = new Date(oDate2[0], oDate2[1] - 1, oDate2[2]);
	iDays = parseInt(Math.abs(strDateS - strDateE) / 1000 / 60 / 60 / 24) //把相差的毫秒数转换为天数 
	return iDays;
}
function CurentTime()  
    {   
        var now = new Date();  
          
        var year = now.getFullYear();       //年  
        var month = now.getMonth() + 1;     //月  
        var day = now.getDate();            //日  
          
        var hh = now.getHours();            //时  
        var mm = now.getMinutes();          //分  
        var ss = now.getSeconds();           //秒  
          
        var clock = year + "-";  
          
        if(month < 10)  
            clock += "0";  
          
        clock += month + "-";  
          
        if(day < 10)  
            clock += "0";  
              
        clock += day + " ";  
          
        /* if(hh < 10)  
            clock += "0";  
              
        clock += hh + ":";  
        if (mm < 10) clock += '0';   
        clock += mm + ":";   
           
        if (ss < 10) clock += '0';   
        clock += ss;    */
        return(clock);   
}  


function checkboxvalues(){
    obj = document.getElementsByName("noBindDev");
    check_val = [];
    for(k in obj){
        if(obj[k].checked)
            check_val.push(obj[k].value);
    }
    console.log(check_val);
    return check_val;
}
///////////关于地图//////////////
map.on('click', function(e) {
        console.log(e);
        $(".address_longitude").val(e.lnglat.getLng());
        $(".address_latitude").val(e.lnglat.getLat());
        //获取详细地址
        getAddressDetail(e.lnglat.getLat(),e.lnglat.getLng());
        map.clearMap();
        var lnglatXY=[e.lnglat.getLng(),e.lnglat.getLat()];
        var marker_obj = new AMap.Marker({  //加点
                map: map,
                title:e.lnglat.getLng() +","+e.lnglat.getLat()
                //position: lnglatXY
            });
        marker_obj.setPosition(lnglatXY);
        })
        
function showMapMark(){
    var lng  = $("input[name='longitude']").val();
    var lat  = $("input[name='latitude']").val();
    map.clearMap();
    var lnglatXY=[lng,lat];
        var marker_obj = new AMap.Marker({  //加点
                map: map,
                title:lng +","+lat
                //position: lnglatXY
                
            });
        marker_obj.setPosition(lnglatXY);
        map.setCenter(lnglatXY);
        map.setZoom(15);
}        
//////////关于地图结束//////////////
		</script>
	</body>
</html>
